/*
	flad : Copyright 2010 Dale J Williams

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/
package lads.flad.utils {
	
	/**
	 * QuickMath: A series of fast-processing Math shortcuts.
	 * @author Dale J Williams
	 * @version 1.0
	 */
	public class QuickMath {
		
		static public const RADIANS	:Number = Math.PI / 180;
		static public const DEGREES	:Number = 180 / Math.PI;
		
		static public function max(value1:Number, value2:Number):Number {
			return value1 > value2 ? value1 : value2;
		}		
		static public function min(value1:Number, value2:Number):Number {
			return value1 < value2 ? value1 : value2;
		}
		static public function abs(value:Number):Number {
			return value < 0 ? -value : value;
		}
		static public function limit(value:Number, min:Number, max:Number):Number {
			value = value > min ? value : min;
			return value < max ? value : max;
		}
		static public function round(value:Number):Number {
			return int(value + 0.5);
		}
		static public function randRange(min:Number, max:Number):Number {
			return Math.random() * (max - min) + min;
		}
		static public function percentChance(percent:Number):Boolean {
			return Math.random()*100 < percent;
		}
		
	}

}